package com.atguigu.guli.service.base.handler;

import com.atguigu.guli.service.base.result.R;
import lombok.Value;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.omg.CORBA.ExceptionList;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import sun.plugin.extension.ExtensionUtils;

/**
 * @author Jia Fa
 * @create 2021-10-26 19:51
 */
@RestControllerAdvice //异常处理注解
@Slf4j
public class GlobalExceptionHandler {

    //定义最大的异常处理器
    @ExceptionHandler(value = Exception.class)
    public R exception(Exception e){
        //org.apache.commons.lang3.exception.ExceptionUtils
        log.error("{}", ExceptionUtils.getStackTrace(e));
        return R.error();
    }
    @ExceptionHandler(value = ArithmeticException.class)
    public R ArithmeticGet(ArithmeticException e){
        log.error("-->{}",ExceptionUtils.getStackTrace(e));
        return R.error();
    }
}
